package com.seelyn.rhea.integrate.spring;

import com.seelyn.rhea.mvc.inject.Injection;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * @author linfeng
 * @since 2016/1/22
 */
public class SpringInjection implements Injection, ApplicationContextAware {

    private ApplicationContext applicationContext;

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
    @Override
    public Object getBean(Class<?> clazz) {
        return applicationContext.getBean(clazz.getSimpleName());
    }

    @Override
    public Object getBean(String name) {
        return applicationContext.getBean(name);
    }

}
